/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.persistence.*;

/**
 *
 * @author akefeli
 */
@Entity
@Table(name = "application")
public class Application implements Serializable {

    public enum Status {

        SUBMITTED,
        UNSUBMITTED
    }

    public enum Evaluation {
        NONE,
        PASS,
        FAIL,
        INCONCLUSIVE
    }
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "APPLICATION_ID", unique = true, nullable = false)
    private Long id;
    @Enumerated(EnumType.STRING)
    private Status status;
    @OneToOne(cascade = CascadeType.ALL)
    private Applicant applicant;
    @Enumerated(EnumType.STRING)
    private Evaluation evaluation;
    private boolean agree;
    @OneToOne(mappedBy = "application",cascade= CascadeType.ALL)
    private EnglishSection englishSection;
    @OneToOne(mappedBy = "application",cascade= CascadeType.ALL)
    private PersonalSection personalSection;
    @OneToOne(mappedBy = "application",cascade= CascadeType.ALL)
    private EducationSection educationSection;
    @OneToOne(mappedBy = "application",cascade= CascadeType.ALL)
    private ProfessionalSection professionalSection;
    @OneToOne(mappedBy = "application",cascade= CascadeType.ALL)
    private ProgrammingSection programmingSection;
    @OneToOne(mappedBy = "application",cascade= CascadeType.ALL)
    private SelfStudySection selfStudySection;

    protected Application() {
    }

    public Application(Applicant applicant) {
        setApplicant(applicant);
    }

    public Long getId() {
        return id;
    }

    public EducationSection getEducationSection() {
        return educationSection;
    }

    public void setEducationSection(EducationSection educationSection) {
        this.educationSection = educationSection;
    }

    public EnglishSection getEnglishSection() {
        return englishSection;
    }

    public void setEnglishSection(EnglishSection englishSection) {
        this.englishSection = englishSection;
    }

    public PersonalSection getPersonalSection() {
        return personalSection;
    }

    public void setPersonalSection(PersonalSection personalSection) {
        this.personalSection = personalSection;
    }

    public ProfessionalSection getProfessionalSection() {
        return professionalSection;
    }

    public void setProfessionalSection(ProfessionalSection professionalSection) {
        this.professionalSection = professionalSection;
    }

    public ProgrammingSection getProgrammingSection() {
        return programmingSection;
    }

    public void setProgrammingSection(ProgrammingSection programmingSection) {
        this.programmingSection = programmingSection;
    }

    public SelfStudySection getSelfStudySection() {
        return selfStudySection;
    }

    public void setSelfStudySection(SelfStudySection selfStudySection) {
        this.selfStudySection = selfStudySection;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Applicant getApplicant() {
        return applicant;
    }

    public void setApplicant(Applicant applicant) {
        if (this.applicant == null) {
            this.applicant = applicant;
            applicant.setApplication(this);
        }
    }

    public boolean isAgree() {
        return agree;
    }

    public void setAgree(boolean agree) {
        this.agree = agree;
    }

    public Evaluation getEvaluation() {
        return evaluation;
    }

    public void setEvaluation(Evaluation evaluation) {
        this.evaluation = evaluation;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Application)) {
            return false;
        }
        Application other = (Application) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Application[ id=" + id + " ]";
    }
}
